import Axios from 'axios'

import Config from '../../config'

const state = {
  lists: []
}

const getters = {
  allList: state => state.lists //获取所有列表
}

const actions = {
  async fetchLists({ commit }) {
    const response = await Axios.get(`${Config.url}/user/list`)
    if (response.data.message) {
      commit('setLists', response.data)
    }
  }
}

const mutations = {
  setLists: (state, lists) => (state.lists = lists)
}

export default {
  state,
  getters,
  actions,
  mutations
}
